package com.example.zsydb.scheduler;


import com.example.zsydb.service.ScheduledTaskService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@AllArgsConstructor
public class PumpjackScheduler {

    ScheduledTaskService scheduledTaskService;


    // 项目启动后延迟1秒执行，之后每隔半小时执行一次
    @Scheduled(initialDelay = 1000, fixedRate = 1800 * 1000)
    public void executeAutomatically() {
        scheduledTaskService.fetchAndProcessData();
    }
}
